<?php


namespace app\voip\func;


use app\voip\model\EGrade;

class GradeFunc
{
    /**
     * @param $data
     * @return array|false
     * @throws \Exception
     */
    static function addAll($data)
    {
        $obj=new EGrade();
        return $obj->saveAll($data);
    }

    /**
     * @param $data
     * @return array
     * @throws \think\exception\DbException
     */
    static function checkSave($data)
    {
        $resultData=[];
        foreach ($data as $key=>$val)
        {
            $res=EGrade::get(['uniqid'=>$key]);
            if ($res){
                $resultData[$key]=$res->id;
            }else{
                $res=EGrade::create($val);
                $resultData[$key]=$res->id;
            }
        }
        return $resultData;
    }

}